﻿
namespace Service
{
    using Data.Repository;
    using System.Linq;
	using System.Collections.Generic;

    public class LanguageService : ILanguageService
    {
        private ILanguageRepository _languageRepository;

        #region ILanguageService Members

        public int CreateNewLanguage(Data.Entity.Language theNewLanguage)
        {
            if (theNewLanguage == null)
            {
                return 0;
            }

			if(_languageRepository == null)
			{
				_languageRepository = new LanguageRepository();
			}

			return _languageRepository.CreateNewLanguage(theNewLanguage);
        }

        public IList<Data.Entity.Language> GetAllLanguage()
        {
            if (_languageRepository == null)
            {
                _languageRepository = new LanguageRepository();
            }

            return _languageRepository.GetAllLanguage();
        }

        public int UpdateLanguage(Data.Entity.Language theLanguage)
        {
            if (theLanguage == null || theLanguage.LanguageId <= 0)
            {
                return 0;
            }

            if (_languageRepository == null)
            {
                _languageRepository = new LanguageRepository();
            }

            return _languageRepository.UpdateLanguage(theLanguage);
        }

		public int DeleteLanguage(int id)
		{
			if(id <= 0)
			{
				return 0;
			}

			if(_languageRepository == null)
			{
				_languageRepository = new LanguageRepository();
			}

			return _languageRepository.DeleteLanguage(id);
		}

		#endregion
	}
}
